/*
 * CommunicationModuleBridgeFromAPI.h
 *
 *  Created on: Dec 12, 2014
 *      Authors: Avihay Avitan & Stefan Farcas
 */

#ifndef COMMUNICATIONMODULEBRIDGEFROMAPI_H_
#define COMMUNICATIONMODULEBRIDGEFROMAPI_H_
#include "ICommunicationModuleBridge.h"

namespace CommunicationModuleSpace {
/**
 * CommunicationModuleBridgeFromAPI implements the ICommunicationModuleBridge using the API GS communication module, see ICommunicationModuleBridge
 */
class CommunicationModuleBridgeFromAPI : public ICommunicationModuleBridge{
public:
	CommunicationModuleBridgeFromAPI();
	virtual ~CommunicationModuleBridgeFromAPI();
	bool transmitINITcommand(long timeout);
	bool transmitGOCMD(long timeout , PassLogger * logger);
	bool sendCommandToSat(long timeout, string commandsContent);
	bool sendENDCommand(long timeout);
	bool isReadyForPass() {return this->isReady;};

private:
	bool sendAndWaitForReceive ( Message request , Message * received ) ;
	bool send(Message message);
	bool receive (Message * received) ;
	bool sendAndWaitForReceiveWithTimeout ( Message request ,Message * received ,  int timeoutsec ) ;
	bool sendWithTimeout(Message message , int timeoutsec );
	bool receiveWithTimeout (Message * received, int timeoutsec ) ;


};

} /* namespace CommunicationModuleSpace */

#endif /* COMMUNICATIONMODULEBRIDGEFROMAPI_H_ */
